<?php


namespace App\Http\Controllers\Passenger\V2\User;


use App\Http\Controllers\Controller;
use App\Services\PassengerPayService;
use App\Services\PassengerUserService;
use Illuminate\Http\Request;

/**
 * Class RechargeController
 * @package App\Http\Controllers\Passenger\V2\User
 * 用户充值
 */
class RechargeController extends Controller
{
    public function userRecharge(Request $request, PassengerPayService $passengerPayService)
    {
        $price = $request->post('price');
        if (empty($price)) return $this->sendError('金额必传');
        $info = $passengerPayService->TopUpBalance($price);
        return $this->sendJson($info);
    }

    /**
     * 余额支付
     */
    public function refund_order(Request $request, PassengerPayService $passengerPayService)
    {
        $order_id = $request->post('id');
        if (empty($order_id)) return $this->sendError('订单ID必须');
        $info = $passengerPayService->BalancePayment($order_id);
        return $this->sendJson($info);
    }

    /**
     * @param PassengerUserService $service
     * @return RechargeController|\Illuminate\Http\JsonResponse
     * 钱包
     */
    public function wallet(PassengerUserService $service)
    {
        return $this->sendJson($service->wallet());
    }
}